package interpreter.bytecodes.debuggerByteCodes;

import interpreter.VirtualMachine;
import interpreter.bytecodes.ByteCode;
import interpreter.debugger.DebugVirtualMachine;
import java.util.Vector;

/**
 *
 * @author Kris Selbekk
 */
public class LineByteCode extends ByteCode {
    private int lineNo;

    public void exec( VirtualMachine rt ) {
        DebugVirtualMachine vm = (DebugVirtualMachine) rt;
        
        vm.setCurrentLine(lineNo);

        // Validates breakpoint
        if( vm.isBreakpoint(lineNo) ) vm.setBreakpoint(lineNo); // SURE?

        // Makes sure step in is not set by default
        if( vm.formalCount() == vm.argCount() ) vm.isStepIn(false);
    }
    public void init( Vector<String> args ) {
        try {
            lineNo = Integer.parseInt(args.get(0));
        } catch( NumberFormatException nfe ) {
            // If bad format
            System.out.println("Bad format!");
            System.exit(-1);
        } catch( NullPointerException npe ) {
            // If argument missing
            System.out.println("Argument given = null.");
            System.exit(-1);
        }
    }
    public Object getArgs() {
        return new Integer(lineNo);
    }
}
